package com.hxd.otc.module.order.presenter;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.order.bean.AllOrderBean;
import com.hxd.otc.module.order.contract.AllOrderContract;
import com.hxd.otc.module.order.model.AllOrderModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

import java.util.List;

/**
 * 作  者 :  zjl
 * 时  间 :  2018/6/4 17:02
 * 描  述 :  ${所有订单页面}
 */
public class AllOrderPresenter extends BasePresenter<AllOrderContract.View> implements AllOrderContract.Presenter {

    AllOrderModel model;

    public AllOrderPresenter(AllOrderContract.View view) {
        super(view);
        model = AllOrderModel.getInstance();
    }

    @Override
    public void start() {

    }


    @Override
    public void doLoadData(boolean isRefresh, int... category) {
        model.getOrderList(new BaseObserver<AllOrderBean>() {
            @Override
            public void onNext(String title, AllOrderBean orderBean) {
                doSetAdapter(orderBean.list);
            }

            @Override
            public void onError(int errType, String errMessage) {
                mView.onError(errType);
                mView.showToast(errMessage);
                doShowNoMore();
            }

        }, mView.<BaseBean<AllOrderBean>>bindAutoDispose(), category[0], category[1], category[2]);

    }

    @Override
    public void doSetAdapter(List<AllOrderBean.DataBean> list) {
        doShowNoMore();
        mView.onSetAdapter(list);
    }

    @Override
    public void doShowNoMore() {
        mView.onShowNoMore();
    }

    @Override
    public void doAdLoadData(boolean isRefresh, int... category) {
//        model.getAdOrderList(new BaseObserver<AllOrderBean>() {
//            @Override
//            public void onNext(String title, AllOrderBean orderBean) {
//                doAdSetAdapter(orderBean.list);
//            }
//
//            @Override
//            public void onError(int errType, String errMessage) {
//                mView.onError(errType);
//                mView.showToast(errMessage);
//                doAdShowNoMore();
//            }
//
//        }, mView.<BaseBean<AllOrderBean>>bindAutoDispose(), category[0], category[1], category[2]);
    }

    @Override
    public void doAdSetAdapter(List<AllOrderBean.DataBean> list) {
        doAdShowNoMore();
        mView.onSetAdAdapter(list);
    }

    @Override
    public void doAdShowNoMore() {

        mView.onAdShowNoMore();
    }

}
